
pkgname=subversion
pkgver=1.10.0
pkgrel=2
pkgdesc="A Modern Concurrent Version Control System"
arch=('x86_64')
url="https://subversion.apache.org/"
license=('APACHE')
depends=('db' 'serf' 'apr-util' 'sqlite3' 'file' 'systemd')
makedepends=('krb5' 'apache' 'python2' 'perl' 'swig' 'ruby' 'java-runtime' 
             'autoconf' 'e2fsprogs') # 'kwallet')
provides=('svn')
options=('!makeflags' '!libtool')
source=("https://www.apache.org/dist/subversion/${pkgname}-${pkgver}.tar.bz2"
        'svn'
        'svnserve.conf' 
        'svnserve.tmpfiles'
        'svnserve.service'
        'subversion.rpath.fix.patch')
sha1sums=('345bc84edc5fe72f70997d247230fd8d3a18d83b'
          '73b36c046c09cec2093354911c89e3ba8056af6c'
          'ad117bf3b2a838a9a678a93fd8db1a066ad46c41'
          '00cc36e69077a8c45674ead6dd62a7647b3a3b6d'
          '9f6790d842cf3e0228b007483a43e39a42724068'
          '3d1e28408a9abb42af2e531adc0d01ce21acfad6')

build() {
   cd ${pkgname}-${pkgver}

   #patch -p0 -i ../subversion.rpath.fix.patch
   
   # configure
   autoreconf
   ./configure --prefix=/usr \
               --with-apr=/usr \
               --with-apr-util=/usr \
               --with-zlib=/usr \
               --with-serf=/usr \
               --with-apxs \
               --with-sqlite=/usr \
               --enable-javahl \
               --without-gnome-keyring \
               --without-kwallet \
               --disable-static \
               --libexecdir=/usr/lib \
               --with-utf8proc=internal

   make 
   make LT_LDFLAGS="-L$Fdestdir/usr/lib" local-all
   make swig_pydir=/usr/lib/python2.7/site-packages/libsvn \
     swig_pydir_extra=/usr/lib/python2.7/site-packages/svn swig-py swig-pl javahl # swig-rb
}

package() {
   cd ${pkgname}-${pkgver}

   export LD_LIBRARY_PATH=${pkgdir}/usr/lib:${LD_LIBRARY_PATH}
   make DESTDIR=${pkgdir} INSTALLDIRS=vendor \
     swig_pydir=/usr/lib/python2.7/site-packages/libsvn \
     swig_pydir_extra=/usr/lib/python2.7/site-packages/svn \
     install install-swig-py install-swig-pl install-javahl # install-swig-rb

   install -d ${pkgdir}/usr/share/subversion
   cp -a tools/hook-scripts ${pkgdir}/usr/share/subversion/
   rm ${pkgdir}/usr/share/subversion/hook-scripts/*.in

   rm ${pkgdir}/usr/lib/perl5/vendor_perl/auto/SVN/_Core/.packlist
   rm -r ${pkgdir}/usr/lib/perl5/core_perl

   ## svnserve
   install -D -m 644 ${srcdir}/svnserve.conf ${pkgdir}/etc/conf.d/svnserve

   # systemd
   install -D -m 644 ${srcdir}/svnserve.service  ${pkgdir}/usr/lib/systemd/system/svnserve.service
   install -D -m 644 ${srcdir}/svnserve.tmpfiles ${pkgdir}/usr/lib/tmpfiles.d/svnserve.conf

   # bash completion
   install -Dm 644 tools/client-side/bash_completion \
     ${pkgdir}/usr/share/bash-completion/completions/subversion
   for i in svn svnadmin svndumpfilter svnlook svnsync svnversion; do
      ln -sf subversion "${pkgdir}"/usr/share/bash-completion/completions/${i}
   done
}
